home *** CD-ROM | disk | FTP | other *** search
- Path: a1200.iaehv.nl!gertjan
- Newsgroups: comp.sys.amiga.programmer
- From: gertjan@a1200.iaehv.nl (Gertjan van Ratingen)
- Subject: Re: File sizes
- References: <4gjs20$i68@btmpjg.god.bel.alcatel.be> <642.6631T1174T964@stud.cs.uit.no>
- X-NewsSoftware: GRn 2.1 Feb 19, 1994
- MIME-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- Message-ID: <gertjan.0ay2@a1200.iaehv.nl>
- Date: Thu, 7 Mar 96 20:15:58 +0100
- Organization: An Amiga node polling off InterNet Access Eindhoven 040-439436
-
-
- In article <642.6631T1174T964@stud.cs.uit.no> magneoe@stud.cs.uit.no (Magne Oestlyngen) writes:
- > >In article <WXQ7y*5+f@yaps.rhein.de>, arno@yaps.rhein.de (Arno Eigenwillig) writes:
- > >|> > What's the best way of finding out the size of a file? Do I have to use
- > >|> > Examine()
- > >..or do it in ANSI-C, by opening the file, seeking to the end of it
- > >and getting the number of bytes returned from fseek().
- >
- > fseek() does not return the number of bytes, but 0 if all went fine, non-0 else.
- > Use ftell() to get the position in the file after fseek().
-
- I do not know how well this one performs compaired to fseek()/ftell(),
- but how about:
-
- #include <sys/stat.h>
-
- struct stat stat;
- off_t size;
-
- lstat(filename, &stat);
- size = stat.st_size;
-
- (you people can figure out the rest of the program :-)
-
- --
- Gertjan 'Bugs' van Ratingen a.k.a. gertjan@a1200.iaehv.nl
- CD-i/Amiga Software Engineer "Trust me, I know what I'm doing" -Sledge Hammer
-